//
//  TMCourseHeaderView.m
//  国学商家管理
//
//  Created by Tao Li on 2018/7/5.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMCourseHeaderView.h"

@implementation TMCourseHeaderView
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(id)initWithFrame:(CGRect)frame{
    
    self=[super initWithFrame:frame];
    
    if (self) {
        [self displayUIs];
    }
    return self;
    
}
- (void)displayUIs{
//    self.imageCellView = [[UIView alloc]init];
//    [self addSubview:self.imageCellView];
//    [self.imageCellView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self).offset(0);
//        make.top.equalTo(self).offset(0);
//        make.right.equalTo(self).offset(0);
//        make.height.mas_equalTo(@203);
//    }];
    self.checkView = [[UIView alloc]init];
    [self addSubview:self.checkView];
    //self.checkView.backgroundColor = [UIColor redColor];
    [self.checkView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.imageCellView.mas_bottom).offset(0);
//        make.left.equalTo(self.imageCellView).offset(0);
        make.left.equalTo(self).offset(0);
        make.top.equalTo(self).offset(0);
        make.bottom.equalTo(self).offset(0);
        make.right.equalTo(self).offset(0);
    }];
//    //line view
//    self.lineView1 = [[UIView alloc]init];
//    self.lineView1.backgroundColor = [UIColor hx_colorWithHexRGBAString:@"#EEEEEE"];
//    [self.imageCellView addSubview:self.lineView1];
//    [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.imageCellView).offset(0);
//        make.bottom.equalTo(self.imageCellView).offset(0);
//        make.right.equalTo(self.imageCellView).offset(0);
//        make.height.mas_equalTo(@1);
//    }];
    self.lineView2 = [[UIView alloc]init];
    self.lineView2.backgroundColor = [UIColor hx_colorWithHexRGBAString:@"#EEEEEE"];
    [self.checkView addSubview:self.lineView2];
    [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.checkView).offset(0);
        make.bottom.equalTo(self.checkView).offset(0);
        make.right.equalTo(self.checkView).offset(0);
        make.height.mas_equalTo(@1);
    }];
//    //imageview
//    self.fristImageView = [[UIImageView alloc]init];
//    [self.imageCellView addSubview:self.fristImageView];
//    self.fristImageView.image = [UIImage imageNamed:@"登录背景"];
//    [self.fristImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.imageCellView).offset(12);
//        make.top.equalTo(self.imageCellView).offset(15);
//        make.width.mas_equalTo(@(169*kWindowW/375));
//        make.height.mas_equalTo(@148);
//    }];
//    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToBuyDiscount:)];
//    self.fristImageView.userInteractionEnabled = YES;
//    [self.fristImageView addGestureRecognizer:tap1];
//    self.secondImageView = [[UIImageView alloc]init];
//    [self.imageCellView addSubview:self.secondImageView];
//    self.secondImageView.image = [UIImage imageNamed:@"登录背景"];
//    [self.secondImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//       // make.left.equalTo(self.fristImageView.mas_right).offset(15*kWindowW/375);
//        make.top.equalTo(self.imageCellView).offset(15);
//        make.right.equalTo(self.imageCellView).offset(-12);
//            make.width.mas_equalTo(@(169*kWindowW/375));
//            make.height.mas_equalTo(@148);
//    }];
//    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToBuyDiscount:)];
//    self.secondImageView.userInteractionEnabled = YES;
//    [self.secondImageView addGestureRecognizer:tap2];
//    //label
//    self.fristLabel = [[UILabel alloc]init];
//    self.fristLabel.font = [UIFont systemFontOfSize:14];
//    self.fristLabel.textColor = [UIColor hx_colorWithHexRGBAString:@"#3B3B3B"];
//    self.fristLabel.text = @"购买优惠券";
//    [self.imageCellView addSubview:self.fristLabel];
//    [self.fristLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.fristImageView.mas_bottom).offset(9);
//        make.centerX.equalTo(self.fristImageView);
//        make.bottom.equalTo(self.imageCellView.mas_bottom).offset(-17);
//    }];
//     UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToBuyDiscount:)];
//    self.fristLabel.userInteractionEnabled = YES;
//    [self.fristLabel addGestureRecognizer:tap4];
//    self.secondLabel = [[UILabel alloc]init];
//    self.secondLabel.font = [UIFont systemFontOfSize:14];
//    self.secondLabel.textColor = [UIColor hx_colorWithHexRGBAString:@"#3B3B3B"];
//    self.secondLabel.text = @"购买优惠券";
//    [self.imageCellView addSubview:self.secondLabel];
//    [self.secondLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.secondImageView.mas_bottom).offset(9);
//        make.centerX.equalTo(self.secondImageView);
//        make.bottom.equalTo(self.imageCellView).offset(-17);
//    }];
//    self.secondLabel.userInteractionEnabled = YES;
//     UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToBuyDiscount:)];
//    [self.secondLabel addGestureRecognizer:tap3];
    //button
    self.titleBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.checkView addSubview:self.titleBtn];
    [self.titleBtn setTitle:@"课程类别" forState:UIControlStateNormal];
    [self.titleBtn setTitleColor:[UIColor hx_colorWithHexRGBAString:@"#3B3B3B"]forState:UIControlStateNormal];
    [self.titleBtn addTarget:self action:@selector(chooseType) forControlEvents:UIControlEventTouchUpInside];
    [self.titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self.checkView);
        //make.top.equalTo(self.checkView.mas_top).offset(18);
       // make.left.equalTo(self.checkView).offset(147);
    }];
    self.imageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.checkView addSubview:self.imageBtn];
    [self.imageBtn setImage:[UIImage imageNamed:@"多边形1"] forState:UIControlStateNormal];
    [self.imageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleBtn.mas_right).offset(2);
        make.centerY.equalTo(self.titleBtn);
    }];
}
- (void)tapToBuyDiscount:(UITapGestureRecognizer *)res{
    if (self.buyDiscount) {
        self.buyDiscount();
    }
}
- (void)chooseType{
    if (self.chooseBlock) {
        self.chooseBlock();
    }
}
@end
